import request from "@/utils/request";
import type { PermissionResponseData, MenuParams } from "@/api/acl/menu/type";
enum API {
  //获取菜单数据
  GETPERMIN_URL = "/admin/acl/permission",
  //新增
  ADDPERMISSION_URL = "/admin/acl/permission/save",
  //修改
  UPDATAPERMISSION = "/admin/acl/permission/update",
  //删除
  REMOVEPERMISSION_URL = "/admin/acl/permission/remove/",
}
//获取菜单数据
export const reqGetPermission = () =>
  request.get<any, PermissionResponseData>(API.GETPERMIN_URL);
//新增和修改
export const reqAddPermissionOrUpdate = (data: MenuParams) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATAPERMISSION, data);
  } else {
    return request.post<any, any>(API.ADDPERMISSION_URL, data);
  }
};
//删除
export const reqRemovePermission = (id: number) =>
  request.delete<any, any>(API.REMOVEPERMISSION_URL + id);
